<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>DOM编程</title>
	<script>
		function empty(){
			//1.获取对象
			var divEle = document.getElementById('div');
			//2.获取DIV内子节点的数量
			
			for(var n=0;n<divEle.childNodes.length;n++){
				divEle.removeChild(divEle.childNodes[n]);
				n--;
			}

		}
	</script>
</head>
<body>
	<p>我是段落</p>
	<div style="border:2px solid #f00" id="div">
		<h1>11</h1>
		<p>22</p>
		<p>33</p>
		<p>44</p>
		<div>
			<ul>
				<li><a href="#">AA</a></li>
				<li><a href="#">BB</a></li>
				<li><a href="#">CC</a></li>
			</ul>
		</div>
	</div>
	<p>我也是段落</p>
	<input type="button" value="单击我,删除DIV内所有的子节点" onclick="empty()">
</body>
</html>